<template>
	<view class="payment-index">
		<view class="payment-money text-c">¥{{this.payRepayType==1?info.remainShouldAssure:info.remainShouldBenTotalAmt}}</view>
		<view class="color-999 mar-t-10 text-c">支付金额</view>
		<view class="font-s-16 fw-b" style="margin-top: 80rpx;">支付方式</view>
		<!-- <view class="payment-type-item flex-align-center" :class="{active: type==1}" @click="type=1" v-if="$common.isWeChat()">
			<static-image src="/pagesA/static/img/bill/payment-wx.png" width="48" height="48" margin-right="16"></static-image>
			<view class="font-s-16 fw-b">微信支付</view>
		</view> -->
		<view class="payment-type-item flex-align-center" :class="{active: type==2}" @click="type=2" style="margin-bottom: 80rpx;">
			<static-image src="/pagesA/static/img/bill/payment-zfb.png" width="48" height="48" margin-right="16"></static-image>
			<view class="font-s-16 fw-b">支付宝支付</view>
		</view>
		<u-button shape="circle" @click="confirm()" type="primary" :custom-style="{background:'#3385FF',fontSize:'32rpx',fontWeight:'bold',height:'100rpx',letterSpacing: '8rpx'}">确认支付</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				payRepayType: 1,
				info:{},
				type: this.$common.isWeChat()?2:2
			}
		},
		onLoad(e) {
			this.payRepayType = e.payRepayType
			this.billId = e.billId
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			getDetail() {
				uni.showLoading({
					mask:true
				})
				this.$request({
					url: '/orderInfo/getOrderInfoBillDeatil',
					method: 'get',
					data:{billId:this.billId}
				}).then(res => {
					this.info = res.data
					if((this.payRepayType==1 && this.info.isAssureRepay==1) || (this.payRepayType==2 && this.info.isBenRepay==1)){
						this.$u.toast((this.payRepayType==1?'担保金':'本金')+'支付成功')
						setTimeout(()=>{
							this.$common.navigateBack()
						},1200)
					}
				})
			},
			confirm(){
				uni.showLoading({
					mask:true
				})
				this.$request({
					url: '/orderInfoRepay/payRepayment',
					method: 'post',
					data:{billId:this.billId,payRepayType:this.payRepayType,type:this.type}
				}).then(res => {
					window.location.href = res.data.payInfo
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.payment-index {
		padding: 80rpx 24rpx;
		.payment-money{
			font-size: 56rpx;
			font-weight: bold;
		}
		.payment-type-item{
			width: 100%;
			height: 112rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			padding: 0 24rpx;
			margin-top: 24rpx;
			&.active{
				border: 1rpx solid #1F78FF;
				background: #EBF3FF;
			}
		}
	}
</style>
